package ch.netcetera.planningpoker.client.ui.participant.create;


import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.dom.client.HasKeyUpHandlers;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

public class CreateParticipantView extends Composite implements
        CreateParticipantPresenter.IView {

    private static CreateGameViewUiBinder uiBinder = GWT
            .create(CreateGameViewUiBinder.class);

    interface CreateGameViewUiBinder extends UiBinder<Widget, CreateParticipantView> {
    }

    @UiField
    Button login;

    @UiField
    TextBox userName;
    
    @UiField
    HasText label;
    
    @UiField
    Image spinner;

    public CreateParticipantView() {
        initWidget(uiBinder.createAndBindUi(this));
    }

    @Override
    public Widget asWidget() {
        return this;
    }

    @Override
    public void addToSlot(Object slot, Widget content) {

    }

    @Override
    public void removeFromSlot(Object slot, Widget content) {

    }

    @Override
    public void setInSlot(Object slot, Widget content) {

    }

    @Override
    public HasClickHandlers getLogin() {
        return login;
    }

    @Override
    public HasText getUserName() {
        return userName;
    }

    @Override
    public void setWaiting(boolean isWaiting) {
        login.setEnabled(!isWaiting);
        spinner.setVisible(isWaiting);
    }

    @Override
    public HasText getLabel() {
        return label;
    }

    @Override
    public HasKeyUpHandlers getUserNameForEnter() {
        return userName;
    }


}
